package com.google.code.jbauble.test.dao;

import java.util.List;

import org.springframework.stereotype.Service;

import com.google.code.jbauble.dao.AbstractDao;
import com.google.code.jbauble.test.model.User;

public class UserDao extends AbstractDao {
	public List<User> findAll() {
		return datastore.createQuery(User.class).asList();
	}
	
	public List<User> findByNameAndGqAge(String name, int age, int pageIndex, int pageSize) {
		return datastore.createQuery(User.class).filter("name =", name).filter("age >", age)
			.offset(pageIndex * pageSize).limit(pageSize).asList();
	}
	
	public void save(User u) {
		datastore.save(u);
	}

	public void deleteAll() {
		datastore.delete(datastore.createQuery(User.class));
	}
}
